const crypto =require('crypto')
module.exports={
    MD5:(pwd)=>{
        let md5=crypto.createHash('md5')
        return md5.update(pwd).digest('hex')
    },
    RESPONSE_CLIENT:(res,httpCode=500,status=3,msg='服务端异常，请稍候再试',data={})=>{
        let resData={
            status,
            msg,
            data
        }
        res.status(httpCode).json(resData)
    },
    FORMAT_TIME:(timestamp)=>{
        const date = new Date(timestamp);
        const Y = date.getFullYear() + '-';
        const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
        const D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
        const h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
        const m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
        const s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
        return Y + M + D + h + m + s;
    }

}
